﻿///****************************************************************************
//**		File: ORelationTransfer.cs
//** 		Desc: 心声传递
//** 		Called by:
//**
//** 		Auth: 陈泳江 （chenyongjiang@sxt.com.cn）
//** 		Date: 2014/6/17 14:12:47
//** ===========================================================================
//** 		Change History
//** ===========================================================================
//** 		Date:		Author:				Description:
//** 		--------	--------			-------------------
//**
//** ===========================================================================
//** Copyright (C) 2004-2011 SXT Corporation
//******************************************************************************/
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Web;
//using System.Data;
//using System.Data.SqlClient;
//using SXT.DB;
//using System.IO;
//using System.Text;
//using SXT.Data;
//namespace ZHDJ.MobileInterface.Common
//{
//    public class XHPartyTransmission
//    {
//        public static bool InsertData(FieldAttribute FA)
//        {
//            if (InsertEx(FA))
//            {
//                string ID = StringHelper.NewID;
//                string[] BranchIDEx = new string[] { FA.BranchID };
//                string[] DeputyEx = new string[] { FA.PartyDeputys };
//                string[] LoginIDEx = new string[] { FA.CreateBy };
//                InterfaceHelper.AddTask(ID, FA.Title, "心声传递",
//                    FA.CreateBy, BranchIDEx,
//                       CommonUtils.AppAddress + "/BranchCenter/Module/FindPartyRepresentative/XHPartySuggestionReply.aspx?RelationID=" + ID + "&SugID=" + FA.ID + "&LoginID=" + FA.CreateBy + "&PageType=done"
//                       , "Branch");
//                InterfaceHelper.AddTask(ID, FA.Title, "心声传递",
//                    FA.CreateBy, DeputyEx,
//                       CommonUtils.AppAddress + "/BranchCenter/Module/FindPartyRepresentative/XHPartySuggestionReply.aspx?RelationID=" + ID + "&SugID=" + FA.ID + "&LoginID=" + FA.CreateBy + "&PageType=done"
//                       , "Branch");
//                InterfaceHelper.AddTask(ID, "心声传递业务码", "心声传递",
//                    FA.CreateBy, LoginIDEx,
//                       CommonUtils.AppAddress + "/BranchCenter/Module/FindPartyRepresentative/SerialNumberView.aspx?RelationID=" + ID + "&ObjID=" + FA.ID + "&PageType=qd"
//                       , "Branch");
//                return true;
//            }
//            else return false;
//        }

//        public static bool InsertEx(FieldAttribute FA)
//        {
//            using (SqlCommand cmd = new SqlCommand())
//            {
//                StringBuilder sbsql = new StringBuilder();
//                sbsql.Append(@" insert into tblXHPartySuggestion(ID,BranchID,UserName,MobileNo,Age,Gender,Post,PoliticsLineament,WorkUnit,Address,Zip,PartyDeputys,PartyDeputyName,Title,Content,CreateTime,CreateBy,Status,SerialNumber)
//                               values(@ID,@BranchID,@UserName,@MobileNo,@Age,@Gender,@Post,@PoliticsLineament,@WorkUnit,@Address,@Zip,@PartyDeputys,@PartyDeputyName,@Title,@Content,@CreateTime,@CreateBy,@Status,@SerialNumber)");
//                cmd.Parameters.Add("@ID", SqlDbType.NVarChar).Value = FA.ID;
//                cmd.Parameters.Add("@BranchID", SqlDbType.NVarChar).Value = FA.BranchID;
//                cmd.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = FA.UserName;
//                cmd.Parameters.Add("@MobileNo", SqlDbType.NVarChar).Value = FA.MobileNo;
//                cmd.Parameters.Add("@Age", SqlDbType.Int).Value = FA.Age;
//                cmd.Parameters.Add("@Gender", SqlDbType.NVarChar).Value = FA.Gender;
//                cmd.Parameters.Add("@Post", SqlDbType.NVarChar).Value = FA.Post;
//                cmd.Parameters.Add("@PoliticsLineament", SqlDbType.NVarChar).Value = FA.PoliticsLineament;
//                cmd.Parameters.Add("@WorkUnit", SqlDbType.NVarChar).Value = FA.WorkUnit;
//                cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value = FA.Address;
//                cmd.Parameters.Add("@Zip", SqlDbType.Int).Value = FA.Zip;
//                cmd.Parameters.Add("@PartyDeputys", SqlDbType.NVarChar).Value = FA.PartyDeputys;
//                cmd.Parameters.Add("@PartyDeputyName", SqlDbType.NVarChar).Value = FA.PartyDeputyName;
//                cmd.Parameters.Add("@Title", SqlDbType.NVarChar).Value = FA.Title;
//                cmd.Parameters.Add("@Content", SqlDbType.NVarChar).Value = FA.Content;
//                cmd.Parameters.Add("@CreateTime", SqlDbType.DateTime).Value = FA.CreateTime;
//                cmd.Parameters.Add("@CreateBy", SqlDbType.NVarChar).Value = FA.CreateBy;
//                cmd.Parameters.Add("@Status", SqlDbType.NVarChar).Value = FA.Status;
//                cmd.Parameters.Add("@SerialNumber", SqlDbType.NVarChar).Value = FA.SerialNumber;
//                cmd.CommandText = sbsql.ToString();
//                return DBManager.DBSettings["SXT.DefaultDBEx"].ExecuteNonQuery(cmd) > 0 ? true : false;
//            }
//        }

//        [DBTable("tblXHPartySuggestion")]
//        public class FieldAttribute : DataModel
//        {
//            #region 属性
//            /// <summary>
//            /// ID
//            /// </summary>
//            [DBField(IsPrimaryKey = true)]
//            public string ID { get; set; }

//            /// <summary>
//            /// BranchID
//            /// </summary>
//            [DBField]
//            public string BranchID { get; set; }

//            /// <summary>
//            /// 编号
//            /// </summary>
//            [DBField]
//            public string SerialNumber { get; set; }

//            /// <summary>
//            /// 主题
//            /// </summary>
//            [DBField]
//            public string Title { get; set; }

//            /// <summary>
//            /// 用户名
//            /// </summary>
//            [DBField]
//            public string UserName { get; set; }
//            /// <summary>
//            /// MobileNo
//            /// </summary>
//            [DBField]
//            public string MobileNo { get; set; }

//            /// <summary>
//            /// 工作单位
//            /// </summary>
//            [DBField]
//            public string WorkUnit { get; set; }

//            /// <summary>
//            /// 职务
//            /// </summary>
//            [DBField]
//            public string Post { get; set; }

//            /// <summary>
//            /// 党代表
//            /// </summary>
//            [DBField]
//            public string PartyDeputys { get; set; }

//            /// <summary>
//            /// 党代表
//            /// </summary>
//            [DBField]
//            public string PartyDeputyName { get; set; }

//            /// <summary>
//            /// 内容
//            /// </summary>
//            [DBField]
//            public string Content { get; set; }

//            /// <summary>
//            /// 状态
//            /// </summary>
//            [DBField]
//            public bool Status { get; set; }

//            /// <summary>
//            /// 回复
//            /// </summary>
//            [DBField]
//            public string Reply { get; set; }

//            /// <summary>
//            /// CreateBy
//            /// </summary>
//            [DBField]
//            public string CreateBy { get; set; }

//            /// <summary>
//            /// 创建时间
//            /// </summary>
//            [DBField]
//            public DateTime? CreateTime { get; set; }

//            /// <summary>
//            /// 修改人
//            /// </summary>
//            [DBField]
//            public string ModifyBy { get; set; }

//            /// <summary>
//            /// 修改时间
//            /// </summary>
//            [DBField]
//            public DateTime? ModifyTime { get; set; }

//            /// <summary>
//            /// 姓别
//            /// </summary>
//            [DBField]
//            public string Gender { get; set; }
//            /// <summary>
//            /// 年龄
//            /// </summary>
//            [DBField]
//            public int Age { get; set; }
//            /// <summary>
//            /// 联系地址
//            /// </summary>
//            [DBField]
//            public string Address { get; set; }
//            /// <summary>
//            /// 邮政编码
//            /// </summary>
//            [DBField]
//            public string Zip { get; set; }
//            /// <summary>
//            /// 政治面貌
//            /// </summary>
//            [DBField]
//            public string PoliticsLineament { get; set; }

//            /// <summary>
//            /// 联系形式
//            /// </summary>
//            [DBField]
//            public string ContactForm { get; set; }
//            #endregion
//        }

//        /// <summary>
//        /// 获取姓名、电话
//        /// </summary>
//        /// <param name="Deputys"></param>
//        /// <returns></returns>
//        public static DataTable GetDeputyName(string Deputys)
//        {
//            using (SqlCommand cmd = new SqlCommand())
//            {
//                StringBuilder sbsql = new StringBuilder();
//                sbsql.Append(@"select UserName,MobileNo from tblPartyOrgMembers where LoginID=@LoginID");
//                cmd.Parameters.Add("@LoginID", SqlDbType.NVarChar).Value = Deputys;
//                cmd.CommandText = sbsql.ToString();
//                DataTable dt = DBManager.DBSettings["SXT.DefaultDBEx"].ExecuteDataSet(cmd).Tables[0];
//                return dt;
//            }
//        }

//        /// <summary>
//        /// 获取系列编号
//        /// </summary>
//        /// <param name="ID"></param>
//        /// <returns></returns>
//        public static DataTable GetSerialNumber(string ID)
//        {
//            using (SqlCommand cmd = new SqlCommand())
//            {
//                StringBuilder sbsql = new StringBuilder();
//                sbsql.Append(@"select * from tblXHPartySuggestion where ID=@ID");
//                cmd.Parameters.Add("@ID", SqlDbType.NVarChar).Value = ID;
//                cmd.CommandText = sbsql.ToString();
//                DataTable dt = DBManager.DBSettings["SXT.DefaultDBEx"].ExecuteDataSet(cmd).Tables[0];
//                return dt;
//            }
//        }

//        /// <summary>
//        /// 创建业务码
//        /// </summary>
//        /// <param name="branchID"></param>
//        /// <returns></returns>
//        public static string GetSerialNumber()
//        {
//            string SerialNumber = "QD" + DateTime.Now.ToString("yyyyMMdd");
//            using (SqlCommand cmd = new SqlCommand())
//            {
//                cmd.CommandText = @"SELECT COUNT(*) FROM tblXHPartySuggestion WHERE  CreateTime>@beginTime and CreateTime < @endTime ";
//                cmd.Parameters.Add("@beginTime", SqlDbType.DateTime).Value = DateTime.Now.Date;
//                cmd.Parameters.Add("@endTime", SqlDbType.DateTime).Value = DateTime.Now.AddDays(1).Date.AddSeconds(-1);
//                object obj = DB.DBManager.DBSettings["SXT.DefaultDBEx"].ExecuteScalar(cmd);

//                if (obj != null && obj.ToString() != "")
//                    return SerialNumber + (Convert.ToInt32(obj) + 1).ToString("D4");
//                else
//                    return SerialNumber + "0001";
//            }
//        }

//        /// <summary>
//        /// 获取党代表名字
//        /// </summary>
//        /// <param name="PartyDeputys"></param>
//        /// <returns></returns>
//        public static DataTable GetPartyDeputyName(string PartyDeputys)
//        {
//            using (SqlCommand cmd = new SqlCommand())
//            {
//                StringBuilder sbsql = new StringBuilder();
//                sbsql.Append(@" select * from tblPartyOrgLeader where 1=1 and ID=@ID");
//                cmd.Parameters.Add("@ID", SqlDbType.NVarChar).Value = PartyDeputys;
//                cmd.CommandText = sbsql.ToString();
//                DataTable dt = DBManager.DBSettings["SXT.DefaultDBEx"].ExecuteDataSet(cmd).Tables[0];
//                return dt;
//            }
//        }
//    }
//}